
<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
	<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>登录页面</title>
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta name="description" content="Free HTML5 Template by FreeHTML5.co" />
	<meta name="keywords" content="free html5, free template, free bootstrap, html5, css3, mobile first, responsive" />
	

  

  	<!-- Facebook and Twitter integration -->
	<meta property="og:title" content=""/>
	<meta property="og:image" content=""/>
	<meta property="og:url" content=""/>
	<meta property="og:site_name" content=""/>
	<meta property="og:description" content=""/>
	<meta name="twitter:title" content="" />
	<meta name="twitter:image" content="" />
	<meta name="twitter:url" content="" />
	<meta name="twitter:card" content="" />

	<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
	<link rel="shortcut icon" href="favicon.ico">

	<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700,300' rel='stylesheet' type='text/css'>
	
	<link rel="stylesheet" href="css/bootstrap.min.css">
	<link rel="stylesheet" href="css/animate.css">
	<link rel="stylesheet" href="css/style.css">


	<!-- Modernizr JS -->
	<script src="js/modernizr-2.6.2.min.js"></script>
	<!-- FOR IE9 below -->
	<!--[if lt IE 9]>
	<script src="js/respond.min.js"></script>
	<![endif]-->

	</head>
	<body class="style-2">

		<div class="container">
		
			<div class="row">
				<div class="col-md-4">
					

					<!-- Start Sign In Form -->
					<form class="fh5co-form animate-box" data-animate-effect="fadeInLeft">
						<h2>登录</h2>
						<div class="form-group" id="loginPhone">
							<label for="phone" class="sr-only">手机号</label>
							<input type="text" class="form-control" id="phone" placeholder="手机号" autocomplete="off">
						</div>
						<div class="form-group" style="display: none;" id="loginName">
							<label for="userName" class="sr-only">用户名</label>
							<input type="text" class="form-control" id="userName" placeholder="用户名" autocomplete="off">
						</div>
						<div class="form-group">
							<label for="password" class="sr-only">Password</label>
							<input type="password" class="form-control" id="password" placeholder="密码" autocomplete="off">
						</div>

						<div class="form-group">
							用户类型：
							<select id="loginType">
								<option>普通用户</option>
								<option>场馆馆主</option>
								<option>后台管理员</option>
							</select>
						</div>

						<div class="form-group">
							<label for="remember"><input type="checkbox" id="remember"> 记住我</label>
						</div>
						<div class="form-group">
							<p>没有注册? <a href="regist.html">注册</a> <!--| <a href="forgetpwd.html">忘记密码?</a>--></p>
						</div>
						<div class="form-group">
							<input type="button" value="登录" class="btn btn-primary" id="signinSubmit">
						</div>
					</form>
					<!-- END Sign In Form -->

				</div>
			</div>
			<div class="row" style="padding-top: 60px; clear: both;">
				<div class="col-md-12 text-center"><p><small>&copy; All Rights Reserved. More Templates <a href="http://www.cssmoban.com/" target="_blank" title="模板之家">模板之家</a> - Collect from <a href="http://www.cssmoban.com/" title="网页模板" target="_blank">网页模板</a></small></p></div>
			</div>
		</div>
	
	<!-- jQuery -->
	<script src="js/jquery.min.js"></script>
	<!-- Bootstrap -->
	<script src="js/bootstrap.min.js"></script>
	<!-- Placeholder -->
	<script src="js/jquery.placeholder.min.js"></script>
	<!-- Waypoints -->
	<script src="js/jquery.waypoints.min.js"></script>
	<!-- Main JS -->
	<script src="js/main.js"></script>


	<script type="text/javascript">
		$(function(){
			$("#loginType").change(function(){
				if ($("#loginType").val()=="后台管理员") {
					$("#loginName").css("display","");
					$("#loginPhone").css("display","none");
				}else{
					$("#loginName").css("display","none");
					$("#loginPhone").css("display","");
				}
			});
		});
		
		
	</script>


	<script type="text/javascript">
        $(function(){

            $('#signinSubmit').click(function(){
                //获取当前项目
                var path = "/" + location.pathname.split("/")[1];
                console.log(path);

                //后台管理员登录
                if($("#loginType").val()=="后台管理员") {
                    if ($('#userName').val() === '') {
                        $(this).text('用户名不能为空');
                    } else if ($('#password').val() === '') {
                        $(this).text('密码不能为空');
                    } else {
                        $(this).text('请稍后...');
                        $.post(path+"/AdminController/login",
                            {"adminName":$('#userName').val(),
                                "adminPassword":$('#password').val(),
                            },
                            function(data){

                                if(data == "true"){

                                    window.location.href = "index.html";
                                }else{
                                    alert("用户名或密码错误");
                                    return false;
                                }
                            },"json");

                    }
                }

                //用户登录
                if($("#loginType").val()=="普通用户") {
                    if ($('#phone').val() === '') {
                        $(this).text('手机号不能为空');
                    } else if ($('#password').val() === '') {
                        $(this).text('密码不能为空');
                    } else {
                        $(this).text('请稍后...');
                        $.post(path+"/UserController/login",
                            {"userPhone":$('#phone').val(),
                                "userPassword":$('#password').val(),
                            },
                            function(data){
                                console.log(data);
                                if(data == "true"){

                                    window.location.href = path+"/user/index.html";
                                }else{
                                    alert("手机号或密码错误");
                                    return false;
                                }
                            },"json");

                    }
                }



                //馆主登录
                if($("#loginType").val()=="场馆馆主") {
                    if ($('#phone').val() === '') {
                        $(this).text('手机号不能为空');
                    } else if ($('#password').val() === '') {
                        $(this).text('密码不能为空');
                    } else {
                        $(this).text('请稍后...');
                        $.post(path+"/ClubController/login",
                            {"clubPhone":$('#phone').val(),
                                "clubPassword":$('#password').val(),
                            },
                            function(data){
                                console.log(data);
                                if(data == "true"){
                                    window.location.href = path+"/club/index.html";
                                }else if(data == "false"){
                                    alert("手机号或密码错误");
                                    return false;
                                }else if(data == "已禁用"){
                                    alert("该用户已禁用，请联系管理员解除禁用");
                                    return false;
                                }else if(data == "待审核"){
                                    alert("该用户正在审核，请耐心等待");
                                    return false;
                                }
                            },"json");

                    }
                }


                });
            });
    </script>

	</body>
</html>

